package org.fast.easy.oss.feign.factory;

import lombok.extern.slf4j.Slf4j;
import org.fast.easy.core.domain.messages.MessagePublishDomain;
import org.fast.easy.core.domain.result.R;
import org.fast.easy.oss.domain.vo.OriginalFile;
import org.fast.easy.oss.domain.vo.RemoteFile;
import org.fast.easy.oss.feign.service.OssFeignService;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import static org.fast.easy.oss.feign.constant.OssServiceNameConstants.OSS_FEIGN_SERVICE_NAME;


/**
 * 类说明
 *
 * @author YanMing
 * @date 2024/5/15
 */
@Slf4j
@Component
public class OssFeignFallbackFactory implements FallbackFactory<OssFeignService>{
    @Override
    public OssFeignService create(Throwable cause) {
        log.error("{}服务调用失败:{}", OSS_FEIGN_SERVICE_NAME, cause.getMessage());
        return new OssFeignService()
        {
            @Override
            public R<RemoteFile> upload(OriginalFile file) {
                return R.fail("上传文件失败:" + cause.getMessage());
            }

        };

    }
}
